using System;
using System.Collections;
using System.Collections.Generic;
using NuoYan;
using NuoYan.Extension;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
public class TextSelector : MonoBehaviour,IPointerClickHandler,IPointerEnterHandler,IPointerExitHandler
{
    private TMP_Text tMP_Text;
    private Canvas canvas;

    private void Awake()
    {
        tMP_Text = GetComponent<TMP_Text>();
        canvas = GetComponentInParent<Canvas>();

        tMP_Text.text = "这是一个测试".LinkString("Test");
    }
    public void OnPointerEnter(PointerEventData eventData)
    {
        tMP_Text.LinkAction(canvas.worldCamera,Color.yellow, e =>
        {
            Debug.Log(e.GetLinkID() + e.GetLinkText());
        }
        );
    }

    public void OnPointerClick(PointerEventData eventData)
    {
        tMP_Text.LinkAction(canvas.worldCamera,Color.red, e =>
        {
            Debug.Log("点击");
        }
        );
    }

    public void OnPointerExit(PointerEventData eventData)
    {
       // tMP_Text.RemoveBackgroundMask();
    }

}
